#!/sbin/openrc-run

name="Sentinel-proxy"
description="A proxy that relays messages received over ZMQ to Sentinel server over MQTT"

: ${command_user:="sentinel"}
: ${cfgfile:="/etc/sentinel/proxy.cfg"}
: ${syslog:="yes"}

command="/usr/bin/sentinel-proxy"
command_args="
	--config=$cfgfile
	${logfile:+"--log-file=$logfile"}
	${loglevel:+"--log-level=$loglevel"}
	$command_args
	"
command_background="yes"
pidfile="/run/$RC_SVCNAME.pid"

required_files="$cfgfile"

depend() {
	need net
	after firewall
}

start_pre() {
	yesno "${syslog-}" && command_args="$command_args --syslog"

	if [ "${logfile-}" ]; then
		checkpath -f -m 640 -o "$command_user" "$logfile" || return 1
	fi
}
